import { defineStore } from 'pinia'

export const useUserStore = defineStore({
  id: 'user',
  state: () => {
    return {
      name: 'ljq'
    }
  },
  persist: {
    enabled: true, // 启用
    strategies: [
      // storage 可选localStorage或sessionStorage
      // paths 给指定数据持久化
      { key: 'user', storage: localStorage, paths: ['name'] }
    ]
  },
  actions: {
    updateName (name:string) {
      this.name = name
    }
  }
})